#include "home_page.h"

void create_home_screen(lv_obj_t * parent) {
    // 创建标题
    lv_obj_t *title = lv_label_create(parent);
    lv_label_set_text(title, "Smart Home Control");
    lv_obj_align(title, LV_ALIGN_TOP_MID, 0, 20);
    
    // 创建控制卡片的容器
    lv_obj_t *card_container = lv_obj_create(parent);
    lv_obj_set_size(card_container, 440, 180);
    lv_obj_align(card_container, LV_ALIGN_TOP_MID, 0, 60);
    lv_obj_set_flex_flow(card_container, LV_FLEX_FLOW_ROW);
    lv_obj_set_flex_align(card_container, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
    lv_obj_set_style_pad_all(card_container, 10, 0);
    lv_obj_set_style_pad_row(card_container, 10, 0);
    lv_obj_set_style_pad_column(card_container, 10, 0);
    
    // 灯光控制卡片
    lv_obj_t *light_card = lv_obj_create(card_container);
    lv_obj_set_size(light_card, 130, 160);
    lv_obj_set_style_radius(light_card, 10, 0);
    lv_obj_set_style_bg_color(light_card, lv_color_hex(0x2196F3), 0);
    lv_obj_set_style_bg_opa(light_card, LV_OPA_COVER, 0);
    
    lv_obj_t *light_icon = lv_label_create(light_card);
    lv_label_set_text(light_icon, LV_SYMBOL_POWER);
    lv_obj_align(light_icon, LV_ALIGN_TOP_MID, 0, 20);
    
    lv_obj_t *light_label = lv_label_create(light_card);
    lv_label_set_text(light_label, "Lighting");
    lv_obj_align(light_label, LV_ALIGN_TOP_MID, 0, 50);
    
    lv_obj_t *light_switch = lv_switch_create(light_card);
    lv_obj_align(light_switch, LV_ALIGN_BOTTOM_MID, 0, -20);
    
    // 温度控制卡片
    lv_obj_t *temp_card = lv_obj_create(card_container);
    lv_obj_set_size(temp_card, 130, 160);
    lv_obj_set_style_radius(temp_card, 10, 0);
    lv_obj_set_style_bg_color(temp_card, lv_color_hex(0xFF4081), 0);
    lv_obj_set_style_bg_opa(temp_card, LV_OPA_COVER, 0);
    
    lv_obj_t *temp_icon = lv_label_create(temp_card);
    lv_label_set_text(temp_icon, LV_SYMBOL_SETTINGS);
    lv_obj_align(temp_icon, LV_ALIGN_TOP_MID, 0, 20);
    
    lv_obj_t *temp_label = lv_label_create(temp_card);
    lv_label_set_text(temp_label, "Temperature");
    lv_obj_align(temp_label, LV_ALIGN_TOP_MID, 0, 50);
    
    lv_obj_t *temp_value = lv_label_create(temp_card);
    lv_label_set_text(temp_value, "25°C");
    lv_obj_align(temp_value, LV_ALIGN_CENTER, 0, 10);
    
    // 窗帘控制卡片
    lv_obj_t *curtain_card = lv_obj_create(card_container);
    lv_obj_set_size(curtain_card, 130, 160);
    lv_obj_set_style_radius(curtain_card, 10, 0);
    lv_obj_set_style_bg_color(curtain_card, lv_color_hex(0x4CAF50), 0);
    lv_obj_set_style_bg_opa(curtain_card, LV_OPA_COVER, 0);
    
    lv_obj_t *curtain_icon = lv_label_create(curtain_card);
    lv_label_set_text(curtain_icon, LV_SYMBOL_IMAGE);
    lv_obj_align(curtain_icon, LV_ALIGN_TOP_MID, 0, 20);
    
    lv_obj_t *curtain_label = lv_label_create(curtain_card);
    lv_label_set_text(curtain_label, "Curtain");
    lv_obj_align(curtain_label, LV_ALIGN_TOP_MID, 0, 50);
    
    lv_obj_t *curtain_slider = lv_slider_create(curtain_card);
    lv_obj_set_size(curtain_slider, 80, 10);
    lv_obj_align(curtain_slider, LV_ALIGN_BOTTOM_MID, 0, -20);
}